<?php

require "include/bittorrent.php";

loggedinorreturn();

if ( $_GET['action'] == 'restore' ) {
	sql_query("UPDATE users SET override_class = 255 WHERE id = ".$CURUSER['id']);
	if ( empty($_SERVER['HTTP_REFERER']) ) RedirectTo('index.php');
	else RedirectTo($_SERVER['HTTP_REFERER']);
	die();
} else {
	if ($CURUSER['class'] < UC_ADMINISTRATOR) stderr($tracker_lang['access_denied']); 
	if ($CURUSER['override_class'] != 255) stderr($tracker_lang['access_denied']); 
	if($_GET['action'] == 'editclass') {
		$newclass = intval($_GET['class']);
		$returnto = 'index.php';
		sql_query("UPDATE users SET override_class = ".sqlesc($newclass)." WHERE id = ".$CURUSER['id']); // Set temporary class
		RedirectTo($returnto);
	} else {
		stdhead($tracker_lang['change'].' '.$tracker_lang['class']);
?>
<h2><?=$tracker_lang['change'].' '.$tracker_lang['class'];?></h2>
<form method="get" action="setclass.php">
<input type=hidden name="action" value="editclass">
<table width="150" border="2" cellspacing="5" cellpadding="5" >
<tr><td><strong><?=$tracker_lang['Class'];?>:</strong> </td><td align="left"><select name="class">
<?
		$maxclass = get_user_class() - 1;
		for ($i = 0; $i <= $maxclass; ++$i) print('<option value='.$i.' .">' . get_user_class_name($i));
?>
</select> <td colspan="3" align="center"> <input type="submit" class="btn" value="<?=$tracker_lang['change'];?>"></td></tr></form>
</form>
</table>
<br />
<?
		stdfoot();
	}
}
?>